NumberHelper
Kind: global class
new NumberHelper()
NumberHelper Class
NumberHelper.isNumber(n) ⇒ boolean
Checks if element is a number
Kind: static method of NumberHelper
Returns: boolean
- Whether the element is a number or not
Param | Type | Description |
---|
n | string | number | The element to check |
NumberHelper.isInt(n) ⇒ boolean
Checks if element is an integer
Kind: static method of NumberHelper
Returns: boolean
- Whether the number is an integer or not
Param | Type | Description |
---|
n | string | number | Number to check |
NumberHelper.isFloat(n) ⇒ boolean
Checks if element is a float number
Kind: static method of NumberHelper
Returns: boolean
- Whether the number is a float or not
Param | Type | Description |
---|
n | string | number | Number to check |
NumberHelper.isEven(n) ⇒ boolean
Checks if number is even
Kind: static method of NumberHelper
Returns: boolean
- Whether the number is even or not
Param | Type | Description |
---|
n | number | Number to check |
NumberHelper.isOdd(n) ⇒ boolean
Checks if number is odd
Kind: static method of NumberHelper
Returns: boolean
- Whether the number is odd or not
Param | Type | Description |
---|
n | number | Number to check |
NumberHelper.isFinite(n) ⇒ boolean
Checks if numer is finite
Kind: static method of NumberHelper
Returns: boolean
- Whether the number is finite or not
Param | Type | Description |
---|
n | number | Number to check |
Checks if number is prime
Kind: static method of NumberHelper
Returns: boolean
- Whether the numbere is prime or not
Param | Type | Description |
---|
num | number | Number to check |
NumberHelper.getRandom(min, max) ⇒ number
Gets random integer number in a range
Kind: static method of NumberHelper
Returns: number
- Random number in range
Param | Type | Description |
---|
min | number | Minimum number |
max | number | Maximum number |
NumberHelper.prefixWithZeros(number, length) ⇒ string
Prefixes a number with zeros until desired length
Kind: static method of NumberHelper
Returns: string
- Padded number as a string
Param | Type | Description |
---|
number | number | Number to pad |
length | number | Desired number length |
NumberHelper.convertToNumber(toCheck, [decimals]) ⇒ number
Converts string to number
Kind: static method of NumberHelper
Returns: number
- Converted number
Param | Type | Default | Description |
---|
toCheck | string | number | | Number-like to convert |
[decimals] | number | 2 | Number of decimals to truncate |
NumberHelper.processNumber(value, [decimals]) ⇒ number
Processes number to get clean value
Kind: static method of NumberHelper
Returns: number
- Parsed and processed number
Param | Type | Default | Description |
---|
value | string | number | | String or number to process |
[decimals] | number | 2 | No. of decimals to truncate to |